# from django.test import TestCase
#
# # Create your tests here.
# # 老年人体检预约接口
# class OldMedicalView(APIView):
#     def post(self, request, *args, **kwargs):
#         # 体检项目id
#         tj_id = request.POST['t_id']
#         agreement_json = TimeQuantumModel.objects.filter(project__p_id=tj_id).all()
#         agreement_lists = (json.loads(serializers.serialize('json', agreement_json)))
#         time_quantum_list = []
#         for agreement_list in agreement_lists:
#             time_quantum_dict = {}
#             point_in_time = []
#             time_quantum_dict['pk'] = agreement_list['pk']
#             time_quantum_dict['t_name'] = agreement_list['fields']['t_name']
#             time_quantum_dict['start_time'] = agreement_list['fields']['start_time']
#             time_quantum_dict['end_time'] = agreement_list['fields']['end_time']
#             data_jsons = DataTimeModel.objects.filter(time__t_id=agreement_list['pk']).all()
#             serialization_list = (json.loads(serializers.serialize('json', data_jsons)))
#             # print(serialization_list)
#             week_list = []
#             week_dict = {}
#             for i in serialization_list:
#                 print(i['pk'])
#                 print(i['fields']['d_data'])
#                 TimeModel.objects.filter(da)
#             #     for a in agreement_list['fields']['d_time']:
#             #         data_jsons = TimeModel.objects.filter(t_id=a)
#             #         point_in_time_dict = {}
#             #         serialization_li = (json.loads(serializers.serialize('json', data_jsons)))
#             #         for b in serialization_li:
#             #             point_in_time_dict['t_name'] = b['fields']['t_name']
#             #             point_in_time_dict['t_number'] = b['fields']['t_number']
#             #             point_in_time_dict['t_start_time'] = b['fields']['t_start_time']
#             #             point_in_time_dict['t_end_time'] = b['fields']['t_end_time']
#             #         point_in_time.append(point_in_time_dict)
#             #     week_dict['week'] = i['fields']['d_data']
#             #     week_dict['time'] = point_in_time
#             #     week_list.append(week_dict)
#             time_quantum_dict['datetime'] = week_list
#             time_quantum_list.append(time_quantum_dict)
#         data = {
#             'msg': "查询成功",
#             'code': 2000,
#             'data': time_quantum_list
#         }
#         return Response(data)
#
#     def get(self, *args, **kwargs):
#         # 时间段字典 time_node_dict{}
#         # 时间段列表 time_node_list[]
#         # 星期字典   week_dict{}
#         # 星期列表   week_list[]
#         # 起始日期    date_dict {}
#         # 起始日期    date_list {}
#
#         data = []
#         date_range = {}
#         agreement_json = TimeQuantumModel.objects.filter(project__p_id="77tuuvzuHbDnq63ZshTgtH").all()
#
#         agreement_lists = (json.loads(serializers.serialize('json', agreement_json)))
#         # print(agreement_lists)
#         week_time_list = []
#         week_time_dict = {}
#         for agreement_list in agreement_lists:
#             print(agreement_list)
#             # 时间段字典
#             time_node_dict = {}
#             # 时间段列表
#             time_node_list = []
#             # 星期字典
#             week_dict = {}
#             # 星期列表
#             week_list = []
#             # 起始日期
#             date_dict = {}
#             # 起始日期
#             date_list = []
#             date_dict['start_date'] = agreement_list['fields']['start_time']
#             date_dict['end_date'] = agreement_list['fields']['end_time']
#             date_list.append(date_dict)
#             date_range['name'] = "可预约日期范围"
#             date_range['week_range'] = date_list
#
#             # # 星期几
#             # what_day_id_list = agreement_list['fields']['d_time']
#             # print(what_day_id_list,"dhfadh")
#
#             data_jsons = DataTimeModel.objects.filter(time__t_id=agreement_list['pk']).all()
#             serialization_list = (json.loads(serializers.serialize('json', data_jsons)))
#             # for serialization_li in serialization_list:
#             #     for what_day_id in what_day_id_list:
#             #         serialization_time = TimeModel.objects.filter(t_id=what_day_id)
#             #         str_time = (json.loads(serializers.serialize('json', serialization_time)))[0]
#             #         time_id = str_time['pk']
#             #         t_number = str_time['fields']['t_number']
#             #         t_start_time = str_time['fields']['t_start_time']
#             #         t_end_time = str_time['fields']['t_end_time']
#             #         time_node_dict['time_id'] = time_id
#             #         time_node_dict['t_number'] = t_number
#             #         time_node_dict['t_start_time'] = t_start_time
#             #         time_node_dict['t_end_time'] = t_end_time
#             #         time_node_list.append(time_node_dict)
#             #     week_time_dict['week'] = serialization_li['fields']['d_data']
#             #     week_time_dict['time'] = time_node_list
#             data.append(time_node_dict)
#             data.append(date_list)
#
#         data = {
#             'msg': "查询成功",
#             'code': 2000,
#             'data': data
#         }
#         return Response(data)
